<?php
Class User_model extends CI_Model{

  /*
  *esta metodo permite verificar usuario y contraseña
  */ 
 function login($username, $password){
   $this -> db -> select('per_id_persona, per_nombre,per_rut, per_password');
   $this -> db -> from('per_persona');
   $this -> db -> where('per_nombre  = ' . "'" . $username . "'");
   $this -> db -> where('per_password = ' . "'" . MD5($password) . "'");
   $this -> db -> limit(1);

   $query = $this -> db -> get();
   
   if($query -> num_rows() == 1){
     return $query->result();
   }
   else{
     return false;
   }
 }


 function registerUser($username,$password,$email){
  $data = array('per_nombre' => $username, 'per_password' => MD5($password), 'email' => $email);
  $this->db->insert('users', $data);
  return $username.$password;
 }


}
?>
